package com.xidian.zhiancloud.controller.riskcontrol.risksystem;

import com.xidian.zhiancloud.controller.base.BaseController;
import com.xidian.zhiancloud.dto.ResultDTO;
import com.xidian.zhiancloud.enums.GeneralResponseEnums;
import com.xidian.zhiancloud.service.riskcontrol.riskevaluate.*;
import com.xidian.zhiancloud.service.riskcontrol.risksystem.TRiskEvaluationMethodService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 系统配置 / 风险评价方法设置
 */
@RestController
@RequestMapping("/evaluationmethod")
public class TRiskEvaluationMethodController extends BaseController {

    @Autowired
    TRiskEvaMethSetConMeasService tRiskEvaMethSetConMeasService;

    @Autowired
    TRiskEvaMethSetCriteService tRiskEvaMethSetCriteService;

    @Autowired
    TRiskEvaMethSetFiveFieldService tRiskEvaMethSetFiveFieldService;

    @Autowired
    TRiskEvaMethSetFreService tRiskEvaMethSetFreService;

    @Autowired
    TRiskEvaMethSetPossService tRiskEvaMethSetPossService;

    @Autowired
    TRiskEvaMethSetSeverService tRiskEvaMethSetSeverService;

    @Autowired
    TRiskEvaluationMethodService tRiskEvaluationMethodService;

    /**
     * 系统配置 / 风险评价方法设置
     * @return 返回 ResultDTO 对象
     */
    @RequestMapping("/getEvaluationMethod")
    public ResultDTO getEvaluationMethod(
          @RequestParam("evaMethodSetId") String evaMethodSetId){
        Long companyId = this.getSessionUserCompanyId();

        List<List<Map<String, Object>>> LS00List= new ArrayList<>();

        List<List<Map<String, Object>>> LEC00List= new ArrayList<>();

        List<List<Map<String, Object>>> MES00List= new ArrayList<>();

        List<List<Map<String, Object>>> LC00List= new ArrayList<>();

        // 两个字段
        // LS00  (1)
        // LEC00 (1)
        // MES00 (1)
        List<Map<String, Object>> criteoneList= tRiskEvaMethSetCriteService
                .getByEvaMethodSetIdOneList(companyId, evaMethodSetId);
        //两个字段
        //LEC00 (2)
        List<Map<String, Object>> critetwoList= tRiskEvaMethSetCriteService
                .getByEvaMethodSetIdTwoList(companyId, evaMethodSetId);

        // 三字段
        // MES00 (2)
        // LC00  (2)
        List<Map<String, Object>> frethreeList= tRiskEvaMethSetFreService
                .getByEvaMethodSetIdTwoList(companyId, evaMethodSetId);

        // 四字段
        // LC00 (1)
        List<Map<String, Object>> possoneList= tRiskEvaMethSetPossService
                .getByEvaMethodSetIdOneList(companyId, evaMethodSetId);

        // 四字段
        // LC00 (3)
        List<Map<String, Object>> possthreeList= tRiskEvaMethSetPossService
                .getByEvaMethodSetIdThreeList(companyId, evaMethodSetId);

        // 四字段
        // MES00 (4)
        // LS00 (4)
        List<Map<String, Object>> possfourList= tRiskEvaMethSetPossService
                .getByEvaMethodSetIdFourList(companyId, evaMethodSetId);

        // 四字段
        // MES00 (5)
        List<Map<String, Object>> possfiveList= tRiskEvaMethSetPossService
                .getByEvaMethodSetIdFiveList(companyId, evaMethodSetId);

        // 五字段
        // MES00 (3)
        List<Map<String, Object>> fivesthreeList=
                tRiskEvaMethSetFiveFieldService
                .getByEvaMethodSetIdThreeList(companyId, evaMethodSetId);

        // 六字段
        // LS00 (2)
        List<Map<String, Object>> conmeastowList=
                tRiskEvaMethSetConMeasService
                        .getByEvaMethodSetIdTwoList(companyId, evaMethodSetId);

        // 六字段
        // LEC00 (3)
        List<Map<String, Object>> conmeasthreeList=
                tRiskEvaMethSetConMeasService
                        .getByEvaMethodSetIdThreeList(companyId, evaMethodSetId);

        // 七字段
        // LS00 (3)
        List<Map<String, Object>> severservicethreeList= tRiskEvaMethSetSeverService
                .getByEvaMethodSetIdThreeList(companyId, evaMethodSetId);

        // 七字段
        // LEC00 (4)
        List<Map<String, Object>> severservicefourList= tRiskEvaMethSetSeverService
                .getByEvaMethodSetIdFourList(companyId, evaMethodSetId);

        LS00List.add(criteoneList);
        LS00List.add(conmeastowList);
        LS00List.add(severservicethreeList);
        LS00List.add(possfourList);

        LEC00List.add(criteoneList);
        LEC00List.add(critetwoList);
        LEC00List.add(conmeasthreeList);
        LEC00List.add(severservicefourList);
        LEC00List.add(possfiveList);

        MES00List.add(criteoneList);
        MES00List.add(frethreeList);
        MES00List.add(fivesthreeList);
        MES00List.add(possfourList);
        MES00List.add(possfiveList);

        LC00List.add(possoneList);
        LC00List.add(frethreeList);
        LC00List.add(possthreeList);

        Map<String, Object> data = new HashMap<String, Object>();
        if(evaMethodSetId.equals("LS00")){
            data.put("LS00List" , LS00List);
        }else if (evaMethodSetId.equals("LEC00")){
            data.put("LEC00List" , LEC00List);
        }else if (evaMethodSetId.equals("MES00")){
            data.put("MES00List" , MES00List);
        }else if (evaMethodSetId.equals("LC00")){
            data.put("LC00List" , LC00List);
        }
        return ResultDTO.successOf(data,GeneralResponseEnums.SUCCESS);
    }


}
